<template>
    <!-- 奖励记录 -->
    <div class="app-container">
        <el-card>
            <el-form size="mini" ref="searchForm" :model="searchForm" inline>
                <el-form-item label="活动名称">
                    <el-input v-model="searchForm.name" placeholder="请输入活动名称"></el-input>
                </el-form-item>
                <el-form-item label="用户ID/手机号">
                    <el-input v-model="searchForm.account" placeholder="请输入用户ID/手机号"></el-input>
                </el-form-item>
                <el-form-item label="用户昵称">
                    <el-input v-model="searchForm.nickname" placeholder="请输入昵称"></el-input>
                </el-form-item>
                <el-form-item label="查询时间：" prop="beginTime">
                    <el-date-picker style="width: 200px" v-model="searchForm.beginTime" align="right" type="date"
                        placeholder="选择开始日期" :picker-options="$pickerDateOptions" value-format="yyyy-MM-dd"
                        format="yyyy 年 MM 月 dd 日">
                    </el-date-picker>
                </el-form-item>
                <el-form-item>-</el-form-item>
                <el-form-item prop="endTime">
                    <el-date-picker style="width: 200px" v-model="searchForm.endTime" align="right" type="date"
                        placeholder="选择结束日期" :picker-options="$pickerDateOptions" value-format="yyyy-MM-dd"
                        format="yyyy 年 MM 月 dd 日">
                    </el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button icon="el-icon-refresh" @click="resetForm('searchForm')">重置</el-button>
                    <el-button icon="el-icon-search" type="primary" @click="handleSearchList()">查询</el-button>
                </el-form-item>
            </el-form>

            <el-table v-loading="listLoading" :data="tableData.data" border stripe size="mini">
                <el-table-column align="center" label="序号" type="index" width="80"></el-table-column>
                <el-table-column align="center" label="用户ID" prop="memberId"></el-table-column>
                <el-table-column align="center" label="用户昵称" prop="userNickname"></el-table-column>
                <el-table-column align="center" label="用户手机号" prop="telephone"></el-table-column>
                <el-table-column align="center" label="活动名称" prop="title"></el-table-column>
                <el-table-column align="center" label="行为" prop="description"></el-table-column>
                <el-table-column align="center" label="金额">
                    <template slot-scope="scope">
                       {{scope.row.price / 100}}元
                    </template>
                </el-table-column>
                <el-table-column align="center" label="创建时间" prop="createTime"></el-table-column>
            </el-table>
            <el-pagination class="pageRight" background layout="total, sizes, prev, pager, next, jumper"
                :page-sizes="[10, 20, 50, 100]" :page-size="searchForm.pageSize" :total="tableData.total"
                @size-change="handleSizeChange" @current-change="handleCurrentChange"></el-pagination>
        </el-card>
    </div>
</template>
<script>
import { getBrokerageRecord } from "@/api/brokerage";
export default {
    data() {
        return {
            searchForm: {
                name: '',
                account: '',
                nickname: '',
                beginTime: '',
                endTime: '',
                pageNum: 1,
                pageSize: 10
            },
            listLoading: false,
            tableData: {
                data: [],
                total: 0
            }
        };
    },
    created() {
        this.getList();
    },
    methods: {
        resetForm() {
            this.searchForm = {
                nickname: '',
                beginTime: '',
                endTime: '',
                pageNum: 1,
                pageSize: 10
            };
            this.getList();
        },
        handleSearchList() {
            this.searchForm.pageNum = 1;
            this.getList();
        },
        getList() {
            this.listLoading = true;
            getBrokerageRecord(this.searchForm).then(res => {
                this.tableData.data = res.data.list
                this.tableData.total = res.data.total
            }).finally(v => {
                this.listLoading = false
            });
        },
        handleSizeChange(val) {
            this.searchForm.pageSize = val
            this.getList()
        },
        handleCurrentChange(val) {
            this.searchForm.pageNum = val
            this.getList()
        },
    },
}
</script>